import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
import Index from './layout/main/index.jsx'
import Login from './views/login/Index'
import { connect } from 'react-redux'

const App = ({isLogin}) => {
  return (
    <Router >
      <Switch>
      <Route path='/login' component = { Login } />
        {
          isLogin
           ? <Route path='/' component = {Index} />
           : <Redirect to = '/login' />
        }
        
      </Switch>
    </Router>
  )
}

// 前端验证
export default connect (
  state => {
    return {
      isLogin: state.getIn(['user', 'isLogin'])
    }
  }
)(App)